// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   register_ok.java

package qcs.config.publics;

import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class register_ok extends HttpServlet
{

	ServletContext application;
	HttpSession session;

	public register_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		nseer_db_backup1 qcs_db = new nseer_db_backup1(dbApplication);
		PrintWriter out = response.getWriter();
		try
		{
			if (qcs_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String type_name = request.getParameter("type_name");
				String type_id = request.getParameter("type_id");
				String kind = request.getParameter("kind");
				String kind_id = request.getParameter("kind_id");
				String sqll = (new StringBuilder("select id from qcs_config_public_char where kind_id='")).append(kind_id).append("' and (type_name='").append(type_name).append("' or type_id='").append(type_id).append("')").toString();
				ResultSet rs = qcs_db.executeQuery(sqll);
				if (rs.next())
				{
					out.println("1");
				} else
				{
					String sql = (new StringBuilder("insert into qcs_config_public_char(kind_id,kind,type_name,type_id) values('")).append(kind_id).append("','").append(kind).append("','").append(type_name).append("','").append(type_id).append("')").toString();
					qcs_db.executeUpdate(sql);
					out.println("2");
				}
				qcs_db.commit();
				qcs_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
